<template>
  <div class="tabbar">
    <van-tabbar v-model="active" inactive-color="#000" route>
      <van-tabbar-item replace icon="shop" to="/">首页</van-tabbar-item>
      <van-tabbar-item replace icon="search" to="/search">分类</van-tabbar-item>
      <van-tabbar-item replace icon="shopping-cart" to="/shopping">购物车</van-tabbar-item>
      <van-tabbar-item replace icon="friends" to="/friends">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      active: 0
    };
  },
  mounted() {
    console.log(this.$route.path);
    this.updateactive();
  },
  methods: {
    updateactive() {
      if (this.$route.path == "/") {
        this.active = 0;
      } else if (this.$route.path == "/search") {
        this.active = 1;
      } else if (this.$route.path == "/shopping") {
        this.active = 2;
      } else if (this.$route.path == "/friends") {
        this.active = 3;
      }
    }
  }
};
</script>

<style>
</style>
